package com.sugo.seckill.utils;

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.Map;

/**
 * @author wesker
 * @date 7/19/2019 5:21 PM
 **/
public class BeanUtils {


    private BeanUtils() {
    }

    /**
     * Map转为对象
     * @param dataMap map
     * @param t 对象的类
     * @author linhx
     * @date 2021/1/31 21:47
     * @return T
     */
    public static <T> T convertMapToObject(Map dataMap, Class<T> t) throws Exception {
        ObjectMapper objectMapper = new ObjectMapper();
        String json = objectMapper.writeValueAsString(dataMap);
        T obj = JSON.parseObject(json, t);
        return obj;
    }
}
